package com.sxm.yiwei.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sxm.yiwei.R;
import com.sxm.yiwei.activitis.MineServicer;

import java.util.HashMap;
import java.util.List;

/**
 * Created by KuKa on 2017/8/3.
 * 收货人列表
 */

public class LinkReserverAdapter extends BaseAdapter {
    Context context;
   public List<HashMap<String, String>> linkList;
    public LinkReserverAdapter(Context context, List<HashMap<String, String>> linkList) {
        this.context=context;
        this.linkList = linkList;
    }

    @Override
    public int getCount() {
        return linkList.size()==0?0:linkList.size();
    }

    @Override
    public Object getItem(int position) {
        return linkList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view = View.inflate(context, R.layout.link_reserver_item,null);
            holder = new ViewHolder();

            holder.address = (TextView) view.findViewById(R.id.rederver_linkaddress);
            holder.name = (TextView) view.findViewById(R.id.rederver_linkname);
            holder.phone = (TextView) view.findViewById(R.id.rederver_linkphone);
            view.setTag(holder);

        }else {
            view=convertView;
            holder = (ViewHolder) view.getTag();
        }
        holder.name.setText(linkList.get(position).get("name"));
        holder.address.setText(linkList.get(position).get("address"));
        holder.phone.setText(linkList.get(position).get("phone"));

        notifyDataSetChanged();
        return view;
    }


    class ViewHolder{
        TextView name,phone,address;
    }
}
